from flask import Flask
from api.user import user_api
from api.patient import patient_api
from api.message import message_api

from flask_bcrypt import Bcrypt
from flask_cors import CORS
import secrets
app = Flask(__name__)
CORS(app)
app.secret_key = secrets.token_hex(16)
bcrypt = Bcrypt(app)
app.register_blueprint(user_api, url_prefix='/user')
app.register_blueprint(patient_api, url_prefix='/patient')
app.register_blueprint(message_api, url_prefix='/message')


class Config(object):
    SQLALCHEMY_DATABASE_URI = 'mysql://root:123456@localhost:3307/hospitalsql'
    SQLALCHEMY_COMMIT_ON_TEARDOWN =False # 请求结束后自动提交数据库中的改动
    SQLALCHEMY_TRACK_MODIFICATIONS=True
# 连接数据库
app.config.from_object(Config)
from models import db
db.init_app(app)



if __name__ == '__main__':
    app.run('127.0.0.1', 8088, debug=True)
